package ch10_thread.thread;

/**
 * 如果在执行过程中，每次循环都调用阻塞方法
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class StopSleepEveryLoop {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            try {
                for (int i = 0; i < 100; i++) {
                    Thread.sleep(1000);
                    System.out.println(i);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        thread.start();
        Thread.sleep(5000);
        thread.interrupt();
    }
}
